home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / lin_alg.lha / lin_alg / vvector.dat < prev   
Text File  |  1993-08-08  |  4KB  |  143 lines

  1.  
  2.  
  3. -------------------------------------------------------------------------------
  4.         Verify Operations on Vectors
  5.  
  6.  
  7. ---> Test allocation and compatibility check
  8. The following vector have been allocated
  9.  
  10. Matrix 1:20x1:1 ''
  11. Matrix 1:20x1:1 ''
  12. Matrix 0:19x1:1 ''
  13. Matrix 1:20x1:1 ''
  14. Status information reported for vector v3:
  15.   Lower bound ... 0
  16.   Upper bound ... 19
  17.   No. of elements 20
  18.   Name 
  19.  
  20. Check vectors 1 & 2 for compatibility
  21. Check vectors 1 & 4 for compatibility
  22. v2 has to be compatible with v3 after resizing to v3
  23. v1 has to be compatible with v5 after resizing to v5.upb
  24.  
  25. Matrix 1:25x1:1 'Vector v5'
  26. Done
  27.  
  28.  
  29. ---> Test operations that treat each element uniformly
  30. Writing zeros to v...
  31. Clearing v1 ...
  32. Comparing v1 with 0 ...
  33. Writing a pattern 3.14159 by assigning to v(i)...
  34. Writing the pattern by assigning to v1 as a whole ...
  35. Comparing v and v1 ...
  36. Comparing (v=0) and v1 ...
  37.  
  38. Clear v and add the pattern
  39.    add the doubled pattern with the negative sign
  40. Element #18 with value -3.14159 differs the most from what
  41. was expected, -3.14159, though the deviation 2.38419e-07 is small
  42.    subtract the trippled pattern with the negative sign
  43.  
  44. Verify comparison operations
  45.    (v=pattern)>0
  46.    (v=pattern)>-pattern
  47.    (v=-pattern)<-pattern/2
  48.  
  49. Assign 2*pattern to v by repeating additions
  50. Assign 2*pattern to v1 by multiplying by two 
  51. Multiply v1 by one half returning it to the 1*pattern
  52.  
  53. Assign -pattern to v and v1
  54. v = sqrt(sqr(v)); v1 = abs(v1); Now v and v1 have to be the same
  55. Element #18 with value 9.86961 differs the most from what
  56. was expected, 9.8696, though the deviation 9.53674e-07 is small
  57.  
  58. Check out to see that sin^2(x) + cos^2(x) = 1
  59. Element #9 with value 1 differs the most from what
  60. was expected, 1, though the deviation 5.96046e-08 is small
  61.  
  62. Verify constructor with initialization
  63.  
  64. Done
  65.  
  66.  
  67. ---> Test Binary Vector operations
  68.  
  69. Verify assignment of a vector to the vector
  70.  
  71. Adding one vector to itself, uniform pattern 3.14159
  72.   subtracting two vectors ...
  73.   subtracting the vector from itself
  74.   adding two vectors together
  75.  
  76. Arithmetic operations on vectors with not the same elements
  77.    adding vp to the zero vector...
  78.    making v = 3*vp and v1 = 3*vp, via add() and succesive mult
  79.    clear both v and v1, by subtracting from itself and via add()
  80. Two #19 elements of the vectors with values -3.8147e-06 and 0
  81. differ the most, though the deviation 3.8147e-06 is small
  82.  
  83. Testing element-by-element multiplications and divisions
  84.    squaring each element with sqr() and via multiplication
  85.    compare (v = pattern^2)/pattern with pattern
  86.  
  87.  
  88. Comparison of two Matrices:
  89. Matrix 2:21x1:1 ''
  90. Matrix 2:21x1:1 ''
  91. Maximal discrepancy            0
  92.    occured at the point        (2,1)
  93.  Matrix 1 element is            3.14159
  94.  Matrix 2 element is            3.14159
  95.  Absolute error v2[i]-v1[i]        0
  96.  Relative error                0
  97.  
  98. ||Matrix 1||               62.8319
  99. ||Matrix 2||               62.8319
  100. ||Matrix1-Matrix2||                0
  101. ||Matrix1-Matrix2||/sqrt(||Matrix1|| ||Matrix2||)    0
  102.  
  103.  
  104. Done
  105.  
  106. ---> Verify norm calculations
  107.  
  108. Assign 10.25 to all the elements and check norms
  109.   1. norm should be pattern*no_elems
  110.   Square of the 2. norm has got to be pattern^2 * no_elems
  111.   Inf norm should be pattern itself
  112.   Scalar product of vector by itself is the sqr(2. vector norm)
  113.  
  114. Assign the arithm progression with 1. term -10.25
  115. and the difference 1
  116.   1. norm should be 100.5
  117.   Square of the 2. norm has got to be n*[ a0^2 + a0*q*(n-1) + q^2/6*(n-1)*(2n-1) ], or 676.25
  118.   Inf norm should be max(abs(a0),abs(a0+(n-1)*q)), ie 10.25
  119.   Scalar product of vector by itself is the sqr(2. vector norm)
  120.  
  121.  
  122. Comparison of two Matrices:
  123. Matrix 1:20x1:1 ''
  124. Matrix 1:20x1:1 ''
  125. Maximal discrepancy            10.25
  126.    occured at the point        (1,1)
  127.  Matrix 1 element is            -10.25
  128.  Matrix 2 element is            0
  129.  Absolute error v2[i]-v1[i]        10.25
  130.  Relative error                2
  131.  
  132. ||Matrix 1||               100.5
  133. ||Matrix 2||               0
  134. ||Matrix1-Matrix2||                100.5
  135. ||Matrix1-Matrix2||/sqrt(||Matrix1|| ||Matrix2||)    1.005e+09
  136.  
  137.  
  138. Construct v1 to be orthogonal to v as v(n), -v(n-1), v(n-2)...
  139. ||v1|| has got to be equal ||v|| regardless of the norm def
  140. But the scalar product has to be zero
  141.  
  142. Done
  143.